package thread;

public class Demo11 {
    public static boolean isQuit=false;
    public static void main(String[] args) throws InterruptedException {

        Thread thread=new Thread(()->{
            while (!isQuit){
                System.out.println("hello Tread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread执行结束");
        });
        thread.start();
        Thread.sleep(2000);
        System.out.println("main线程尝试终止thread线程");
        isQuit=true;

    }

}
